import React, { Component } from 'react';
import { View, Text } from '@tarojs/components'
import { AtIcon } from 'taro-ui'
import Taro from '@tarojs/taro'
import './Shouye.css'
import IndexLunbo from './lunbo'
import NewList from './newlist'
class shouye extends Component {
  constructor(props) {
    super(props)
    this.state = {
      isShowLogin: true
    }
  }
  //跳到搜索
  toSearch = () => {
    Taro.navigateTo({
      url: '/pages/search/search'
    })
  }
  componentWillMount() {
    let isLogin = sessionStorage.getItem('isLogin');
    let userId = sessionStorage.getItem('userId');
    if (isLogin && userId) {
      this.setState({
        isShowLogin: false
      })
    }
    else {
      this.setState({
        isShowLogin: true
      })
    }
  }
  //跳到登录
  tologin() {
    Taro.navigateTo({
      url: '/pages/search/search'
    })
  }
  render() {
    return (
      <View>
        <View className='homeTitle'>
          <Text className='searchLeft' onClick={this.toSearch}><AtIcon value='search' size='30' color='#FFFFFF'></AtIcon></Text>
          首页</View>
        <IndexLunbo></IndexLunbo>
        <View className='jianxi'></View>
        <NewList></NewList>
        {this.state.isShowLogin && <View className='islogin'>
          <Text className='loginTT'>登录开启品质生活</Text>
          <Text className='loginBtn' onClick={this.tologin.bind(this)}>立即登录</Text>
        </View>}
      </View>
    );
  }
}

export default shouye;